﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Drawing;
using System.Windows.Forms;
using System.Collections.Specialized;
using System.ComponentModel;
using QASampling.BusinessObject;
using QASampling.UI;

namespace QASampling.QAControl
{
    public class QATableButton : System.Windows.Forms.Button
    {
        /*[Editor("System.Windows.Forms.Design.StringCollectionEditor,System.Design,Version=2.0.0.0,Culture=neutral,PublicKeyToken=b03f5f7f11d50a3a", typeof(System.Drawing.Design.UITypeEditor))]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]*/
        private ToolTip tooltip;

        private string tableSource = string.Empty;
        public string TableSource
        {
            get { return tableSource; }
            set { tableSource = value; }
        }

        private string[] fieldName;
        public string[] FieldName
        {
            get { return fieldName; }
            set { fieldName = value; }
        }

        private string[] fieldValue;
        public string[] FieldValue
        {
            get { return fieldValue; }
            set { fieldValue = value; }
        }

        private string[] originalValue;
        public string[] OriginalValue
        {
            get { return originalValue; }
            set { originalValue = value; }
        }

        private string[] labelText;
        public string[] LabelText
        {
            get { return labelText; }
            set { labelText = value; }
        }

        private int[] fieldLength;
        public int[] FieldLength
        {
            get { return fieldLength; }
            set { fieldLength = value; }
        }

        private JenisField[] fieldType;
        public JenisField[] FieldType
        {
            get { return fieldType; }
            set { fieldType = value; }
        }

        private JenisCommand fieldCommand;
        public JenisCommand FieldCommand
        {
            get { return fieldCommand; }
            set { fieldCommand = value; }
        }

        private string[] dateFormat;
        public string[] DateFormat
        {
            get { return dateFormat; }
            set { dateFormat = value; }
        }

        private string tableNo = string.Empty;
        public string TableNo
        {
            get { return tableNo; }
            set { tableNo = value; }
        }

        private int[] digits;
        public int[] Digits
        {
            get { return digits; }
            set { digits = value; }
        }

        public QATableButton()
        {
            Init();
        }

        private void Init()
        {
            this.Layout += new LayoutEventHandler(QATableButton_Layout);
            this.tooltip = new ToolTip();
            this.Click += new EventHandler(QATableButton_Click);
            if (fieldCommand.Equals(JenisCommand.Insert))
                this.BackgroundImage = global::QASampling.Properties.Resources.Insert;
            else if (fieldCommand.Equals(JenisCommand.Delete))
                this.BackgroundImage = global::QASampling.Properties.Resources.Delete;
            else if (fieldCommand.Equals(JenisCommand.Update))
                this.BackgroundImage = global::QASampling.Properties.Resources.Edit_Table;
            this.Size = new Size(30, 30);
            this.Text = string.Empty;
            this.MouseHover += new EventHandler(QATableButton_MouseHover);
        }

        void QATableButton_Layout(object sender, LayoutEventArgs e)
        {
            if (fieldCommand.Equals(JenisCommand.Insert))
                this.BackgroundImage = global::QASampling.Properties.Resources.Insert;
            else if (fieldCommand.Equals(JenisCommand.Delete))
                this.BackgroundImage = global::QASampling.Properties.Resources.Delete;
        }

        void QATableButton_MouseHover(object sender, EventArgs e)
        {
            tooltip.Show(fieldCommand.ToString(), this);
        }

        void QATableButton_Click(object sender, EventArgs e)
        {
                  
        }
    }
}
